﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using YemekteyizLib.Bs;
using YemekteyizLib;
using System.Web.Security;

public partial class giris : System.Web.UI.Page
{
 
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        //SqlCommand cmd = new SqlCommand("select * from Uyeler where Email=@Email and Sifre=@Sifre", con);

        //cmd.Parameters.AddWithValue("@Email", TextBox1.Text);
        //cmd.Parameters.AddWithValue("@Sifre", TextBox2.Text);
        //string user = string.Empty;
        //cmd.Connection.Open();
        //SqlDataReader rdr = cmd.ExecuteReader();

        //if (rdr.HasRows)
        //{
        //    rdr.Read();
        //    user = rdr[5].ToString();
        //}

        //cmd.Connection.Close();
        //if (user != string.Empty)
        //{
        //    Session["Email"] = user;
        //    Response.Redirect("Default.aspx");
        //}
        //else
        //{
        //    TextBox1.Text = "";
        //    TextBox2.Text = "";
        //    Label3.Text = "Hatalı Giriş";
        //}

        Uye u = UyeProvider.Giris(TextBox1.Text, TextBox2.Text);
        if (u == null)
        {
            Label3.Text = "Giriş başarısız";
            TextBox1.Text = "";
            TextBox2.Text = "";
            TextBox1.Focus();
        }
        else
        {
            Session["uye"] = u;
            FormsAuthentication.RedirectFromLoginPage(u.KullaniciAdi, true);
        }
    }
}
